package com.summer.springboot.mybatisplus.multiple.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.summer.springboot.mybatisplus.multiple.entity.Log;
import com.summer.springboot.mybatisplus.multiple.mapper.LogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class LogServiceImpl implements LogService {

    @Autowired
    private LogMapper logMapper;

    @Override
    @DS("second")
    public void save(Log log) {
        logMapper.insert(log);
    }

    @Override
    @DS("second")
    public void delUser(Long id) {
        logMapper.deleteById(id);
    }

    @Override
    @DS("second")
    public void updateUser(Log log) {
        logMapper.updateById(log);
    }

    @Override
    @DS("second")
    public Log getById(Long id) {
        return logMapper.selectById(id);
    }

    @Override
    @DS("second")
    public List<Log> getAll() {
        return logMapper.selectList(null);
    }
}
